<?php
/**
 * Created by PhpStorm.
 * User: jochen
 * Date: 16/8/19
 * Time: 下午4:05
 */

namespace App\Plugins\Wechat;

use MongoDB\Client;

class DB
{
    static $conns = [];
    static public function createDb($uin) {
        if (!isset(self::$conns[$uin])) {
            $connection = new Client('mongodb://' . env('DB_HOST'));
            self::$conns[$uin] = $connection;
        }
        $collection = self::$conns[$uin]->selectCollection('plugin_wechat_messages', "uin$uin");
        return $collection;
    }
}